
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyJsp.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" href="cssdtree/dtree.css" type="text/css"></link>
	<link href="cssdtree/bootstrap.css" rel="stylesheet">
	<link rel="stylesheet" href="css/main.css">

	<script src="js/jquery.js"></script>
	<script type="text/javascript" src="cssdtree/dtree.js"></script>
	<script src="js/bootstrap.min.js"></script>
	

  </head>
  <script language="javascript">
  $(function(){
 //alert(1);
	var url = "servlet/GetAllUnitsServlet";
	$.post(url,null,function(data){
		var objs = eval(data);
		for(var i=0;i<objs.length;++i)
		{
			$("#department").append("<option value='"+objs[i]+"'>"+objs[i]+"</option>");
		}
	});
	
  
//$(function(){
	//alert(1);   
   	tree = new dTree('tree');//创建一个对象. 
 	$("#btnid").click(function(){
 		$.ajax({  
 		    url: "servlet/ViewServlet?cmp="+$("#cmp").val()+"&department="+$("#department").val()+"",  
 		    type:'post', //数据发送方式  
 		    dataType:'xml', //接受数据格式  
 		    error:function(json){  
 		             alert( "not lived!");  
 		       },  
 		    async: false ,//同步方式  
 		    success: function(xml){  
 		         $(xml).find("node").each(function(){  
 		        var nodeId=$(this).attr("nodeId");   
 		         var parentId=$(this).attr("parentId");   
 		        var hrefAddress=$(this).attr("hrefAddress");   
 		        var nodeName=$(this).text();  
 		        tree.add(nodeId,parentId,nodeName,hrefAddress,"","","","",false);  
 		                        });  
 		           }  
 		     });    
      		document.write(tree);
			
        
        });
   }); 
        </script>
  <body>
    <div id="" style="width:900px;margin:auto;">	
       <div style="background-color:#efefef;height:85px">	
       <div>
       <table class="table table-hover">
         <tr>
            <td class="">按名片所有者查询：</td>
            <td>
                  <select id="department" >   
                       <option value="all" selected="selected">全体</option>   
                       <option value="my"  >自己所有名片</option>
					  
					  
                  </select>
		    </td> 
        </tr>
        <tr>
            <td>按名片中的公司名查询：</td>
		    <td><input id="cmp" type="text" name="cmp" value="" /></td>
            <td> <button id="btnid" type="button"  class="btn btn-primary btn-sm">查看视图</button></td>
   	    </tr>
   	  </table>     	
    </div>
</div>

    	</div>
    		<div id="treediv">
    	</div>
    	<br/>
    	<iframe   name="content" id="content" width="900px" height="500px" frameborder="no"/>
    	
	
  </body>
</html>
